from main import Check_sys
import sys

data = sys.argv[1]

records = Check_sys.select().where(Check_sys.created_date == data, Check_sys.which_eye == 'L').order_by(
    Check_sys.number)
degree_desp = {0: '无病变', 1: '眼科就诊详查', 2: '有病变', 1000: '眼科就诊详查'}
level_desp = {0: '未见DR', 1: '轻度NPDR', 2: '中度NPDR', 3: '重度NPDR', 4: 'PDR', 1000: '无法诊断'}
none_dr_lesion_desp = ['无', 'AMD', '视盘病变', 'RVO', 'PM', 'EMR', '其他']
quality_desp = {0: '良好', 1: '影响诊断', 2: '无法诊断', 3: '有伪影'}

print('编号\t姓名\t调查日期\t左眼严重病变\t左眼分级\t左眼其他病变\t左眼图片质量\t右眼严重病变\t右眼分级\t右眼其他病变\t右眼图片质量')
for r in records:
    try:
        rec = Check_sys.get(Check_sys.number == r.number, Check_sys.which_eye == 'R')
        print(int(r.number),
              r.name,
              r.created_date.replace('_', '-'),
              degree_desp[int(r.degree)],
              level_desp[int(r.level)],
              r.none_dr_lesion,
              quality_desp[r.image_quality],
              degree_desp[int(rec.degree)],
              level_desp[int(rec.level)],
              rec.none_dr_lesion,
              quality_desp[rec.image_quality], sep='\t')
    except:
        # print(r.number, r.name)
        pass
